﻿using System;
using System.Collections.Generic;

namespace Foreglance.MVP.Models
{
    public static class Repository
    {
        static readonly Dictionary<Type, object> _instances = new Dictionary<Type, object>();

        public static T GetInstance<T>() where T: class, new()
        {
            var typeKey = typeof(T);
            if (!_instances.ContainsKey(typeKey))
                _instances.Add(typeKey, new T());
            return (T) _instances[typeKey];
        }
    }
}
